package com.wx.springboot.step9back.service.impl;

import com.wx.springboot.step9back.common.util.MyDate;
import com.wx.springboot.step9back.mapper.TeamMapper;
import com.wx.springboot.step9back.mapper.TransferTeamMapper;
import com.wx.springboot.step9back.model.Team;
import com.wx.springboot.step9back.model.TransferTeam;
import com.wx.springboot.step9back.service.TeamInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service("teamInfoService")
public class TeamInfoServiceImpl implements TeamInfoService {

    @Autowired
    private TransferTeamMapper transferTeamMapper;

    @Override
    public List<TransferTeam> getSelectList(Map<String, Object> data) {
        int page = Integer.parseInt((String) data.get("pageNum"));
        int size = Integer.parseInt((String)data.get("pageSize"));
        data.put("pageNum",(page-1)*size);
        data.put("pageSize",size);
        return transferTeamMapper.getSelectList(data);
    }

    @Override
    public int getSelectCount(Map<String, Object> data) {
        return transferTeamMapper.getSelectCount(data);
    }

    @Override
    public int delTeamInfo(TransferTeam transferTeam) {
        return transferTeamMapper.delTeamInfo(transferTeam);
    }

    @Override
    public String batchDeletion(List<Integer> ids) {
        Map params = new HashMap();
        params.put("ids",ids);
        params.put("updateTime",MyDate.getDate());
        int result = transferTeamMapper.batchDeletion(params);
        if (result>0){
            return "success";
        }else {
            return "false";
        }
    }

    @Override
    public TransferTeam getTeamInfoById(Integer id) {
        return transferTeamMapper.getTeamInfoById(id);
    }
}
